package com.central.common.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.central.common.enums.DbType;
import com.central.common.handler.ListColumnToStringHandler;
import com.central.common.handler.ListIndexToStringHandler;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

import static com.baomidou.mybatisplus.annotation.FieldStrategy.NOT_NULL;

/**
 * @author Tindy
 * @date 2021/7/5
 * @describe
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "table_info",autoResultMap = true)
public class TableInfo extends SuperEntity {
    //数据源id
    private Long datasourceId;
    //数据源类型
    private DbType datasourceType;
    //数据库id
    private Long databaseId;
    private String dbName;
    //表名称
    private String tableName;
    //表注释
    private String tableComment;
    //建表语句
    private String ddl;
    //字段信息列表
    @TableField(jdbcType = JdbcType.VARCHAR, insertStrategy = NOT_NULL, typeHandler = ListColumnToStringHandler.class)
    private List<ColumnInfo> columns;
    //表索引信息
    @TableField(jdbcType = JdbcType.VARCHAR, insertStrategy = NOT_NULL, typeHandler = ListIndexToStringHandler.class)
    private List<IndexInfo> indexs;
    @TableField(exist = false)
    private String previewData;
}
